﻿@using Zj.CourseManage.DTO.Common.Pagination
@model PaginatedList<TeacherVm>
@{
    ViewData["Title"] = "教师列表";
}
<h2>@ViewData["Title"]</h2>
<hr />
<a asp-action="Create" class="text-success">教书录入</a>
<hr />
<form class="form-inline" role="form" method="get" asp-action="Create">
    <div class="form-group">
        <label class="sr-only" for="name">@Html.DisplayNameFor(x => Model.FirstOrDefault().Name)</label>
        <input type="email" class="form-control" id="name" placeholder="@Html.DisplayNameFor(x => Model.FirstOrDefault().Name)" value="@ViewData["searchString"]">
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
    <a asp-action="index">显示所有</a>
</form>
<hr />
<table class="table-bordered table-striped table-condensed table table-responsive">
    <tr>
        <th>
            <a asp-route-searchString="@ViewData["searchString"]" asp-route-sortField="@ViewData["sortId"]">@Html.DisplayNameFor(x => Model.FirstOrDefault().Id)</a>
        </th>
        <th>
            <a asp-route-searchString="@ViewData["searchString"]" asp-route-sortField="@ViewData["sortName"]">@Html.DisplayNameFor(x => Model.FirstOrDefault().Name)</a>
        </th>
        <th>
            <a asp-route-searchString="@ViewData["searchString"]" asp-route-sortField="@ViewData["sortHireDate"]">@Html.DisplayNameFor(x => Model.FirstOrDefault().Office)</a>
        </th>
        <th>
            <a asp-route-searchString="@ViewData["searchString"]" asp-route-sortField="@ViewData["searchString"]">@Html.DisplayNameFor(x => Model.FirstOrDefault().HireDate)</a>
        </th>
        <th>操作</th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(x => item.Id)
            </td>
            <td>
                @Html.DisplayFor(x => item.Name)
            </td>
            <td>
                @Html.DisplayFor(x => item.Office.Name)
            </td>
            <td>
                @Html.DisplayFor(x => item.HireDate)
            </td>
            <th><a asp-action="Delete" asp-route-id="@item.Id">删除</a></th>
        </tr>
    }
</table>
@{
    var previousDiable = Model.HasPrevious ? "" : "disabled";
    var nextDiable = Model.HasNext ? "" : "disabled";
    var previous = (int)ViewData["pageIndex"] - 1;
    var next = (int)ViewData["pageIndex"] + 1;
}
<nav aria-label="...">
    <ul class="pager">
        <li><a  class="btn @previousDiable" asp-action="Index"  asp-route-searchString="@ViewData["searchString"]" asp-route-pageIndex="@previous">Previous</a></li>
        <li><a  class="btn @nextDiable" asp-action="Index"  asp-route-searchString="@ViewData["searchString"]" asp-route-pageIndex="@next">Next</a></li>
    </ul>
</nav>

